Repository navigation
Conversation
Mpdreamz
left a comment
There was a problem hiding this comment.
55 seconds not worth it IMO.
Let's wait for the components/new layouts to land and then re-focus on this?
5a23291 to
d155b4a
Compare
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4959/ |
d155b4a to
5c8dcca
Compare
|
@Mpdreamz agreed, and the minifier is gone. This PR now drops template indentation with a single pass over each page ( |
572f481 to
f1cfdd0
Compare
66ff1d8 to
a5aec07
Compare
a5aec07 to
f6202c5
Compare
f6202c5 to
9ab1873
Compare
d7a18ba to
a53f313
Compare
a53f313 to
bd6f0e8
Compare
bd6f0e8 to
f3e6c46
Compare
eb11e88 to
99564f6
Compare
After the sidebar and row changes, 58 API pages are still over Googlebot's 2 MB limit, many only just. Each API page is now rendered in memory, and `HtmlWhitespace.Collapse` turns every whitespace run in text that holds a line break into one line break before the page is written. Tags, comments and raw-text elements are kept as they are. It is a single pass, not a regex. A regex over the whole page took about 25 s across all API pages, did not scale across threads, and ran past its match timeout on the largest pages, failing their whole API. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A raw-text element now ends only at its own closing tag: the name followed by whitespace, '/' or '>', so `</script-example>` does not close a script. Inside a `pre`, tags are skipped whole, so a `</pre>` in an attribute value does not end it. `MemoryFileSystemStream` decodes its buffer in place instead of copying the page twice. A generator test checks that written rows lose their indentation and keep `hidden="until-found"`, and the large-page test checks output, not time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside a `pre`, a comment went through the tag scan, so a quote after an `=` in it paired with a later attribute's quote and hid the `</pre>`. The rest of the page was then left uncollapsed. Comments now end at `-->`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Inside a `pre`, a `textarea`, `script` or `style` holds raw text, so a `<!--` in it is not a comment. Read as one with no `-->`, it left the rest of the page uncollapsed. A nested raw-text element now ends at its own closing tag before comments are looked for. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each `pre` nested in a `pre` was a recursive call, so deep enough nesting overflowed the stack and ended the build with no error to catch. A `pre` now counts its nested `pre` elements in a loop. Only a `textarea`, `script` or `style` inside it is scanned by a call, and raw text holds no elements, so that goes one level deep at most. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
API pages moved from api/doc/<key> to api/<key> on main. The test's attribute example uses data-tooltip, now that tippy.js is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
99564f6 to
0a3244d
Compare
API pages are now written without their template indentation. API HTML is another 1.9% smaller, and 12 more pages get under Googlebot's 2 MB limit. The parsed pages are unchanged, and the docs build takes the same time.
Affects: API reference
Stack: 4 of 4, on top of #4956, #4955 and #4953.
Prompt summary: Finish the stack with the simpler whitespace collapse from #4944 instead of the WebMarkupMin minifier from #4945. The goal behind the stack is elastic/docs-eng-team#1183: bring API pages under Googlebot's 2 MB HTML limit.
Why
After #4952 to #4956, 58 API pages are still over 2 MB, many of them only just. The property row partial repeats thousands of times on those pages, and its tabs and line breaks are written out each time.
What
Each API page is rendered in memory and written without its indentation
OpenApiGeneratorrenders each page into aMemoryFileSystemStream.HtmlWhitespace.Collapsethen turns every whitespace run in text that holds a line break into one line break, which renders the same underwhite-space: normal. Tags with their attribute values, comments, andpre,textarea,scriptandstyleelements are kept as they are. Only HTML's own whitespace counts, so a non-breaking space is never dropped.A single pass, not a regex
#4944 did this with a regex over the whole page. Measured over all 7,243 API pages, that regex took 25 s and barely sped up on 18 threads (23 s). In one build it ran past its 10 s match timeout on the largest pages, so the whole Kibana and Elasticsearch APIs failed to generate. It also dropped a non-breaking space that sat next to a line break.
HtmlWhitespacenow walks the page once, copying markup through and collapsing only the whitespace in text. It takes 2.2 s over the same pages and gives the same output on every one of them.Results
An isolated build of
docs/with the native AOT binary:mainpreblocks: all 3,413preblocks in the Elasticsearch operation pages are byte-identical.The WebMarkupMin variant of this step (#4945) reaches 41 pages over 2 MB, but adds about 55 s to every build, a dependency, and a workaround for
hidden="until-found".Out of scope: the 46 pages still over 2 MB need content changes, listed on elastic/docs-eng-team#1183.
Verify
Check on the preview
or.🤖 Generated with Claude Code